<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="box"></div>

    <script>
      var startDay = new Date(2024, 0, 0);

      function getDay(x, y) {
        var setDate = new Date(2024, x - 1, y);

        var timeGap = setDate - startDay;
        var seconds = Math.floor(timeGap / 1000);
        var minutes = Math.floor(seconds / 60);
        var hours = Math.floor(minutes / 60);
        var days = Math.floor(hours / 24);
        hours %= 24;
        minutes %= 60;
        seconds %= 60;
        var box = document.querySelector(".box");
        box.textContent = `2024年${x}月${y}日是2024年的第${days}天`;
      }
      getDay(1, 2);
    </script>
  </body>
</html>
